import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import cv2
import numpy as np
from feature_detection import computeHarrisValues, detectCorners, computeMOPSDescriptors, produceMatches
from plot_matches import drawPercent
# visualize original images
img1 = cv2.imread('resources/triangle1.jpg', cv2.IMREAD_COLOR)
img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2RGB)
img2 = cv2.imread('resources/triangle1.jpg', cv2.IMREAD_COLOR)
img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2RGB)
f, axarr = plt.subplots(1, 2)
axarr[0].imshow(img1)
axarr[1].imshow(img2)
<matplotlib.image.AxesImage at 0x13bad9c90>
# compute Harris corner detection and MOPS for img1
img1_norm = img1.astype(np.float32)/255.
grayImage1 = cv2.cvtColor(img1_norm, cv2.COLOR_BGR2GRAY)
(harrisImg1, orientationImg1) = computeHarrisValues(grayImage1)
corners1 = detectCorners(harrisImg1,orientationImg1)
#compute Harris corner detection and MOPS for img2
img2_norm = img2.astype(np.float32) / 255.
grayImage2 = cv2.cvtColor(img2_norm, cv2.COLOR_BGR2GRAY)
(harrisImg2, orientationImg2) = computeHarrisValues(grayImage2)
corners2 = detectCorners(harrisImg2,orientationImg2)
# 79.9% matched and the threshold is 10^(-2).
vis = drawPercent(79.9, img1, img2, -2, corners1, corners2)
plt.figure(figsize=(15, 20))
plt.axis('off')
plt.imshow(vis)
<matplotlib.image.AxesImage at 0x107841a90>
# visualize original images
img1 = cv2.imread('resources/yosemite/yosemite1.jpg', cv2.IMREAD_COLOR)
img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2RGB)
img2 = cv2.imread('resources/yosemite/yosemite2.jpg', cv2.IMREAD_COLOR)
img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2RGB)
f, axarr = plt.subplots(1, 2)
axarr[0].imshow(img1)
axarr[1].imshow(img2)
<matplotlib.image.AxesImage at 0x13d17f790>
# compute Harris corner detection and MOPS for img1
img1_norm = img1.astype(np.float32)
img1_norm /= 255.
grayImage1 = cv2.cvtColor(img1_norm, cv2.COLOR_BGR2GRAY)
(harrisImg1, orientationImg1) = computeHarrisValues(grayImage1)
corners1 = detectCorners(harrisImg1,orientationImg1)
#compute Harris corner detection and MOPS for img2
img2_norm = img2.astype(np.float32)
img2_norm /= 255.
grayImage2 = cv2.cvtColor(img2_norm, cv2.COLOR_BGR2GRAY)
(harrisImg2, orientationImg2) = computeHarrisValues(grayImage2)
corners2 = detectCorners(harrisImg2,orientationImg2)
# 9.9% matched and the threshold is 10^(-.8).
vis = drawPercent(9.9, img1, img2, -.8, corners1, corners2)
plt.figure(figsize=(15, 20))
plt.axis('off')
plt.imshow(vis)
<matplotlib.image.AxesImage at 0x13d1dc450>
# visualize original images
img1 = cv2.imread('resources/graf/img1.png', cv2.IMREAD_COLOR)
img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2RGB)
img2 = cv2.imread('resources/graf/img2.png', cv2.IMREAD_COLOR)
img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2RGB)
f, axarr = plt.subplots(1, 2)
axarr[0].imshow(img1)
axarr[1].imshow(img2)
<matplotlib.image.AxesImage at 0x13c544450>
# compute Harris corner detection and MOPS for img1
img1_norm = img1.astype(np.float32)
img1_norm /= 255.
grayImage1 = cv2.cvtColor(img1_norm, cv2.COLOR_BGR2GRAY)
(harrisImg1, orientationImg1) = computeHarrisValues(grayImage1)
corners1 = detectCorners(harrisImg1,orientationImg1)
#compute Harris corner detection and MOPS for img2
img2_norm = img2.astype(np.float32)
img2_norm /= 255.
grayImage2 = cv2.cvtColor(img2_norm, cv2.COLOR_BGR2GRAY)
(harrisImg2, orientationImg2) = computeHarrisValues(grayImage2)
corners2 = detectCorners(harrisImg2,orientationImg2)
# 5.6% matched and the threshold is 10^(-.8).
vis = drawPercent(5.6, img1, img2, -.8, corners1, corners2)
plt.figure(figsize=(15, 20))
plt.axis('off')
plt.imshow(vis)
<matplotlib.image.AxesImage at 0x13bbc9b50>
# visualize original images
img1 = cv2.imread('resources/heart1.jpg', cv2.IMREAD_COLOR)
img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2RGB)
img2 = cv2.imread('resources/heart2.jpg', cv2.IMREAD_COLOR)
img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2RGB)
f, axarr = plt.subplots(1, 2)
axarr[0].imshow(img1)
axarr[1].imshow(img2)
<matplotlib.image.AxesImage at 0x13d1b9690>
# compute Harris corner detection and MOPS for img1
img1_norm = img1.astype(np.float32)
img1_norm /= 255.
grayImage1 = cv2.cvtColor(img1_norm, cv2.COLOR_BGR2GRAY)
(harrisImg1, orientationImg1) = computeHarrisValues(grayImage1)
corners1 = detectCorners(harrisImg1,orientationImg1)
#compute Harris corner detection and MOPS for img2
img2_norm = img2.astype(np.float32)
img2_norm /= 255.
grayImage2 = cv2.cvtColor(img2_norm, cv2.COLOR_BGR2GRAY)
(harrisImg2, orientationImg2) = computeHarrisValues(grayImage2)
corners2 = detectCorners(harrisImg2,orientationImg2)
# 2.6% matched and the threshold is 10^(-5).
vis = drawPercent(2.6, img1, img2, -5, corners1, corners2)
plt.figure(figsize=(15, 20))
plt.axis('off')
plt.imshow(vis)
<matplotlib.image.AxesImage at 0x13bbdbd10>